package com.example.new_trace_pda_check;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

/**
 * @作者(author): WR
 * @创建时间(date): 2020/11/17
 */
public class MyReceiver extends BroadcastReceiver {

    private RequestResult<String> requestString;

    public MyReceiver(RequestResult<String> requestString) {
        this.requestString = requestString;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String barcode = intent.getStringExtra("barcode");
        if (!TextUtils.isEmpty(barcode)) {
            requestString.request(intent.getStringExtra("barcode"));
        }
    }

    public interface RequestResult<T> {
        void request(T t);
    }

}
